<template>
  <div>
  <div>
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="房间号">
        <el-input v-model="rid" placeholder="顾客房间号"></el-input>
      </el-form-item>
      <el-form-item label="身份证号">
         <el-input v-model="cid" placeholder="顾客身份证号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="finishOrder" :disabled="cid === null || rid===null? true:false">退房</el-button>
      </el-form-item>
    </el-form>
  </div>
    <div v-if="isShowOrder">
      <el-descriptions title="用户信息">
        <el-descriptions-item label="订单编号">{{orderInfo.oid}}</el-descriptions-item>
        <el-descriptions-item label="身份证号">{{orderInfo.cid}}</el-descriptions-item>
        <el-descriptions-item label="用户名">{{cusInfo.name}}</el-descriptions-item>
        <el-descriptions-item label="房间号">{{orderInfo.rid}}</el-descriptions-item>

        <el-descriptions-item label="手机号">{{cusInfo.telnum}}</el-descriptions-item>
        <el-descriptions-item label="会员等级">   <el-tag size="small">{{cusInfo.grade1.gradename}}</el-tag></el-descriptions-item>
        <el-descriptions-item label="享受折扣">{{cusInfo.grade1.discount}}</el-descriptions-item>
        <el-desccusInfoptions-item label="入住时间">{{orderInfo.starttime}}</el-desccusInfoptions-item>
        <el-descriptions-item label="截止时间">{{orderInfo.endtime}}</el-descriptions-item>
        <el-descriptions-item label="离开时间">{{orderInfo.realtime}}</el-descriptions-item>
        <el-descriptions-item label="实际付款">{{orderInfo.realprice}}</el-descriptions-item>
        <el-descriptions-item label="订单备注">{{orderInfo.remark}}</el-descriptions-item>
        <br>
      </el-descriptions>
      <el-link type="success" @click="toHome">返回主页面</el-link>
    </div>
  </div>
</template>
<script>
import instance from "@/untils";
import axios from "axios";

export default {
  data() {
    return {
      rid:null,
      cid:null,
      isShowOrder:false,
      orderInfo:{},
      cusInfo:{},
      roomInfo:{}
    }
  },
  methods: {
    onSubmit() {
      console.log('submit!');
    },
    finishOrder(){
      instance.get("/order/finish/"+this.rid+'/'+this.cid).then(res=>{
        if(res.data.status==200){
          this.$message({
            message:res.data.msg,
            type:"success"
          });
          this.orderInfo=res.data.data;
          instance.get("/cus/getById/"+this.cid).then(res=>{
         this.cusInfo=res.data.data;
          })
          this.isShowOrder=true;
        }
      })
    },
    toHome(){
      this.$router.push('/')
    }
  }

}
</script>

<style scoped>

</style>